package 算法.贪心算法;

import java.util.*;
//https://leetcode-cn.com/problems/minimum-subsequence-in-non-increasing-order/
public class 非递增顺序的最小子序列 {
    public static void main(String[] args) {
        List<Integer> s = minSubsequence(new int[]{4,3,10,9,8});
        System.out.println(s);
    }
    public static List<Integer> minSubsequence(int[] nums) {

       Arrays.sort(nums);

        List<Integer> s = new ArrayList<>();

        int listCount = 0;
        int numsCount = 0;
        for (int num : nums) {
            numsCount += num;
        }
        for(int i = nums.length-1; i >= 0; i--){
            if(listCount > numsCount) break;
            listCount += nums[i];
            numsCount -= nums[i];
            s.add(nums[i]);

        }
        return s;
    }
}
